/**
 * Description:
 * Class Name:FileOutputStreamTest
 * Date:2022/5/1 17:16
 *
 * @author LTisme
 * @version JAVA17
 */
package 疯狂Java讲义.第15章_输入输出._15_3_字节流和字符流._15_3_2_OutputStream和Writer;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class FileOutputStreamTest {
    public static void main(String[] args) {
        String path = "./src/" + FileOutputStreamTest.class.getName().replace(".", "/") + ".java";
        try (var fis = new FileInputStream(path);
             var fos = new FileOutputStream("Chapter_15_newFile.txt")){
            var bbuf = new byte[32];
            var hasRead = 0;
            while ((hasRead = fis.read(bbuf)) > 0){
                // 每读取一次，就写入文件输出流，读了多少就写多少
                fos.write(bbuf, 0, hasRead);
            }
        }
        catch (IOException ioe){
            ioe.printStackTrace();
        }
    }
}
